// notification-plugin.js  
export default { 
    install(app, options = {}) {  
      const defaultOptions = {  
        position: 'top-right',  
        duration: 3000,  
      };  
    
      const finalOptions = { ...defaultOptions, ...options };  
    
      // 创建一个通知组件  
      const NotificationComponent = {  
        template: `  
          <div class="notification" :style="style">  
            <span>{{ message }}</span>  
          </div>  
        `,  
        data() {  
          return {  
            visible: true,  
            message: '',  
          };  
        },  
        computed: {  
          style() {  
            return {  
              position: finalOptions.position,  
              opacity: this.visible ? 1 : 0,  
              transition: 'opacity 0.5s',  
            };  
          },  
        },  
        methods: {  
          hide() {  
            this.visible = false;  
            setTimeout(() => {  
              this.$destroy();  
              this.$el.remove();  
            }, 500);  
          },  
        },  
        mounted() {  
          setTimeout(() => {  
            this.hide();  
          }, finalOptions.duration);  
        },  
      };  
    
      // 创建一个通知管理器  
      const NotificationManager = {  
        createNotification(message) { 
          alert("插件生效" + message ); 
          // const vm = new Vue({  
          //   render: h => h(NotificationComponent, { data: { message } }),  
          // }).$mount();  
    
          // document.body.appendChild(vm.$el);  
        },  
      };  
    
      // 将通知管理器添加到全局属性中  
      app.config.globalProperties.$notify = NotificationManager.createNotification;  
    },  
  };